<?php

namespace App\Http\Requests;

use App\Http\Requests\Request;

class UserUpdateRequest extends Request
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
        'uname'=>'required|regex:/^[a-zA-Z][a-zA-Z0-9_]{5,17}$/',
        'email'=>'required|email',
        'tel'=>'required|regex:/^[1][358][0-9]{9}$/',
        ];
    }

    /**
     * 获取已定义验证规则的错误消息。
     *
     * @return array
     */
    public function messages()
    {
        return [
            'uname.required' => '用户名不能为空',
            'email.required' => '邮箱不能为空',
            'tel.required' => '手机不能为空',
            'uname.regex'  => '用户名需要6-18位字母数字下划线组成',
            'email.email'  => '邮箱格式不正确',
            'tel.regex'  => '手机号码格式不正确',
        ];
    }
}
